package Ui;


/*
 * @author Paolo Cordova
 */

public class PieceLeft extends PieceState {

	private static PieceLeft INSTANCE = null;

	protected PieceLeft() 
	{
		
	}

	public static PieceLeft Instance() 
	{
		if (INSTANCE == null) {
			INSTANCE = new PieceLeft();
		}

		return INSTANCE;
	}

	public void move(final Piece piece, int currentSpace, int newSpace) {
		while (currentSpace != newSpace) {
			piece.pixelX_ = moveSquareLeft(piece, piece.pixelX_, piece.pixelY_, 1);
			currentSpace++;

			if (currentSpace >= 10) {
				piece.pixelX_ = moveSquareLeft(piece, piece.pixelX_, piece.pixelY_, xBuffer);
				
				piece.pixelY_ = moveSquareUp(piece, piece.pixelX_, piece.pixelY_, leftDownYBuffer);
				
				piece.changeState(PieceUp.Instance());
				piece.getState().move(piece, currentSpace, newSpace);
				break;
			}
		}
	}
}